
$(document).ready(function(){
	var rootPath = getRootPath();
	var phone = '';
	var submitDateFrom = '';
	var submitDateEnd = '';
	var startDateFrom = '';
	var startDateEnd = '';
	var appointmentStatus = '';
	var userId = getQueryParamValue("userId");
	var potentialUserId = getQueryParamValue("potentialUserId");
	var dealerCode = getQueryParamValue("dealerCode");
	
	$.ajax({
		method : 'get',
		url : rootPath+'/wechat/api/testdrivingAppointment?phone='+phone+'&submitDateFrom='+submitDateFrom+'&submitDateEnd='+submitDateEnd+'&startDateFrom='+startDateFrom+'&startDateEnd='+startDateEnd+'&appointmentStatus='+appointmentStatus,
		error:function(XMLHttpRequest, ajaxOptions, thrownError){
			alert("连接服务器错误!");
		},
		success : function(resultData){
			
			var wholeHtml = '';
			
			$.each(resultData,function(testdrivingIndex,testdrivingObj){
				
				var testdrivingHtml = '';
				
				var color = '';
				
				if(testdrivingObj.status=='待确认'||testdrivingObj.status=='待试驾'){
					color = '#F15C5C';
				}else if(testdrivingObj.status=='已试驾'){
					color = '#76CBFF';
				}else{
					color = '#B7B7B7';
				}
				
				var testdriveAppointmentId = testdrivingObj.testdriveAppointmentId;
				
				testdrivingHtml = testdrivingHtml + '<div class="panel panel-default">'
												  + '<a href="testdrivinginfor.html?testdriveAppointmentId='+testdriveAppointmentId+'&userId='+userId+'&dealerCode='+dealerCode+'&potentialUserId='+potentialUserId+'" class="list-group-item clearfix">'
												  + '<div style="width:70%;float:left">'
												  + '<p style="font-family:黑体;font-size:15px">'+ testdrivingObj.packageCodeName + '</p>'
												  + '<p style="font-family:黑体;font-size:15px">试驾时间：' + testdrivingObj.startDate + '</p>'
												  + '</div>'
												  + '<div style="width:30%;float:right;text-align:right">'
												  + '<p style="width:70%;float:right;font-family:黑体;font-size:13px;color:'+ color +'">'+ testdrivingObj.status + '</p>'
												  + '<br><br><p style="float:right" class="glyphicon glyphicon-chevron-right"></p>'
												  + '</div>'
												  + '</a>'
												  + '</div>'
				
				wholeHtml += testdrivingHtml;
			});
			
			$("#all").append(wholeHtml);
		}
	});
})
